package info.xmlprint.ui.navigator;

import info.xmlprint.run.Constants;

import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.navigator.IDescriptionProvider;

public class ViewLabelProvider extends LabelProvider implements ILabelProvider,
		IDescriptionProvider {

	public Image getImage(Object element) {
		if (element instanceof IProject) {
			IProject project = (IProject) element;
			if (project.isOpen()) {
				return new Image(null, this.getClass().getResourceAsStream(
						Constants.OBJ_PROJECT_IMG));
			} else {
				return new Image(null, this.getClass().getResourceAsStream(
						Constants.OBJ_PROJECT_CLOSED_IMG));
			}
		}

		return null;
	}

	public String getText(Object element) {
		if (element instanceof IProject) {
			return ((IProject) element).getName();
		}
		return null;
	}

	public String getDescription(Object anElement) {
		if (anElement instanceof IProject) {
			//TODO
		}
		return null;
	}

}